<?php

namespace app\common\model;

use think\Model;
use traits\model\SoftDelete;

class Serviceorderrefund extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'service_order_refund';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'order_status_text',
        'status_text'
    ];
    

    
    public function getOrderStatusList()
    {
        return ['-1' => __('Order_status -1'), '0' => __('Order_status 0'), '1' => __('Order_status 1'), '2' => __('Order_status 2'), '3' => __('Order_status 3'), '4' => __('Order_status 4'), '5' => __('Order_status 5'), '6' => __('Order_status 6')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }


    public function getOrderStatusTextAttr($value, $data)
    {
        $value = $value ?: ($data['order_status'] ?? '');
        $list = $this->getOrderStatusList();
        return $list[$value] ?? '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ?: ($data['status'] ?? '');
        $list = $this->getStatusList();
        return $list[$value] ?? '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
